import java.util.*;

class Node {

    int x;
    int y;

    public Node(int x,int y) {
        this.x = x;
        this.y = y;
    }
}


public class Demo1 {
    //board:迷宫矩阵 clo:行  row:列
    //x,y:当前坐标
    //index:标记数组 是否走过
    //path当前的路径
    //pathMin最短路径
    public static void func(int[][] board,int col,int row,
                            int x,int y,int[][] index,ArrayList<Node> path,ArrayList<Node> pathMin) {

        if(x < 0 || x >= col || y < 0 || y >= row || board[x][y] == 1 || index[x][y] == 1) {
            return;
        }

        index[x][y] = 1;
        path.add(new Node(x,y));

        //是否到达终点,是否是最短路径
        if(x == col - 1 && y == row - 1) {
            if( pathMin.isEmpty() || path.size() < pathMin.size()) {
                pathMin.clear();
                for(Node node:path) {
                    pathMin.add(node);
                }
            }
        }

        func(board,col,row,x-1,y,index,path,pathMin);
        func(board,col,row,x+1,y,index,path,pathMin);
        func(board,col,row,x,y-1,index,path,pathMin);
        func(board,col,row,x,y+1,index,path,pathMin);
        path.remove(path.size() - 1);
        index[x][y] = 0;
    }


    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        while(scan.hasNextInt()) {
            int col = scan.nextInt();
            int row = scan.nextInt();
            int[][] board  = new int[col][row];
            int[][] index = new int[col][row];


            for(int i = 0; i < col; i++) {
                for(int j = 0; j < row; j++) {
                    board[i][j] = scan.nextInt();
                }
            }

            ArrayList<Node> path = new ArrayList<Node>();
            ArrayList<Node> pathMin = new ArrayList<Node>();

            func(board,col,row,0,0,index,path,pathMin);

            for(Node node : pathMin) {
                System.out.println("(" + node.x + "," + node.y +")");
            }
        }
    }
}
